import { uniappMockResponse, uniappRequestAdapter } from '@alova/adapter-uniapp'
import { createAlovaMockAdapter, type MockWrapper } from '@alova/mock'

const mockApis = import.meta.glob<MockWrapper>(['../../mock/**/*.ts', '!@/mock/_utils.ts'], {
  eager: true,
  import: 'default',
})
const mockList = []
for (const path in mockApis) {
  mockList.push(mockApis[path])
}

// 模拟数据请求适配器
const mockAdapter = createAlovaMockAdapter(mockList, {
  // 指定uniapp请求适配器后，未匹配模拟接口的请求将使用这个适配器发送请求
  httpAdapter: uniappRequestAdapter,

  //  模拟响应适配器，指定后响应数据将转换为uniapp兼容的数据格式
  onMockResponse: uniappMockResponse,
})

export { mockAdapter }
